package com.lg.erp.service.impl.zhangchaofu;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lg.erp.entity.zhangchaofu.Stock;
import com.lg.erp.mapper.zhangchaofu.StockMapper;
import com.lg.erp.service.zhangchaofu.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StockServiceImpl implements IStockService {

    @Autowired
    private StockMapper stockMapper;

    @Override
    public IPage<Stock> findStockAll(Page<Stock> page) {
        Long count = stockMapper.selectCount();
        long current = page.getCurrent();
        long size = page.getSize();
        long start = (current-1)*size;
        page.setTotal(count);
        page.setRecords(stockMapper.selectStockAll(start,size));
        return page;
    }

    @Override
    public List<Stock> findStockSearch(String search) {
        return stockMapper.selectStockSearch(search);
    }

    @Override
    public List<Stock> findStockSub(String productNo, String wareId, String product) {
        return stockMapper.selectStockSub(productNo,wareId,product);
    }
}
